package com.tiger.transaction.sample3;

public abstract class BankAccountBean implements javax.ejb.EntityBean {
	private javax.ejb.EntityContext entityContext = null;

	public void setEntityContext(javax.ejb.EntityContext entityContext) {
		this.entityContext = entityContext;
	}

	public void unsetEntityContext() {
		this.entityContext = null;
	}

	public abstract String getName();

	public abstract void setName(String name);

	public abstract int getBalance();

	public abstract void setBalance(int balance);

	public void withdraw(int money) throws IllegalAccountStateException {
		int balance = getBalance();
		if (balance > money)
			setBalance(balance - money);
		else
			throw new IllegalAccountStateException("残高以上の金額を引き出そうとしました");
	}

	public void deposit(int money) {
		int balance = getBalance();
		setBalance(balance + money);
	}

	public String ejbCreate(String name) throws javax.ejb.CreateException {
		setName(name);
		setBalance(0);
		return name;
	}

	public void ejbPostCreate(String name) {
	}

	public void ejbStore() {
	}

	public void ejbActivate() {
	}

	public void ejbPassivate() {
	}

	public void ejbLoad() {
	}

	public void ejbRemove() {
	}
}
